a68916c9baf5eafb74225aad968f4ae9c82275fb,testenrichers/cdi/src/main/java/org/jboss/arquillian/testenricher/cdi/SecurityActions.java,SecurityActions,newInstance,#String#Class[]#Object[]#Class#,125
Before Change
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments,
final Class<T> expectedType)
{
if (className == null)
{
throw new IllegalArgumentException("ClassName must be specified");
}
if (argumentTypes == null)
{
throw new IllegalArgumentException("ArgumentTypes must be specified. Use empty array if no arguments");
}
if (arguments == null)
{
throw new IllegalArgumentException("Arguments must be specified. Use empty array if no arguments");
}
final Object obj;
try
{
final ClassLoader tccl = getThreadContextClassLoader();
final Class<?> implClass = Class.forName(className, false, tccl);
Constructor<?> constructor = getConstructor(implClass, argumentTypes);
obj = constructor.newInstance(arguments);
}
catch (Exception e)
{
throw new RuntimeException("Could not create new instance of " + className
+ ", missing package from classpath?", e);
}
// Cast
try
{
return expectedType.cast(obj);
}
catch (final ClassCastException cce)
{
// Reconstruct so we get some useful information
throw new ClassCastException("Incorrect expected type, " + expectedType.getName() + ", defined for "
+ obj.getClass().getName());
}
}
After Change
}
}
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType)
{
return newInstance(className, argumentTypes, arguments, expectedType, getThreadContextClassLoader());
}
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType, ClassLoader classLoader)